<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>佣金转余额</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="../css/style.css"/>
		<link rel="stylesheet" href="../css/iconfont.css" />
		<link rel="stylesheet" href="../css/wallet.css" />
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
		    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left" href="JavaScript:history.go(-1)"></a>
		    <h1 class="mui-title">佣金转余额</h1>
		</header>
		<div class="mui-content yongj_content">
		    <div class="tixian_pri">
		    	<p>提现到余额(扣除5%服务费)/可提现佣金：<em id='yongj'></em>￥</p>
		    	<p class="tixian_prinum clearfix">
		    		<label>¥</label>
		    		<input type="text" onkeyup="clearNoNums(this)" placeholder="" id='money'/>
		    	</p>
		    </div>
		    <button class="wallet_btn" id='quren' style="width: 100%;color: #fff;">确认</button>
		</div>
	</body>

</html>
<script src="../js/mui.min.js"></script>

<script type="text/javascript" src="../js/jquery.min.js"></script>
<script type="text/javascript" src="../js/layer/layer.min.js"></script>
<script type="text/javascript" src="../js/app.js"></script>
<script type="text/javascript">
	checkLogin(APP.web_root+'member/login.html');
	
	mui.init()
	function clearNoNums(obj)
	{
	   	obj.value = obj.value.replace(/[^\d.]/g,"");  //清除“数字”和“.”以外的字符
	   	obj.value = obj.value.replace(/^\./g,"");  //验证第一个字符是数字而不是.
	   	obj.value = obj.value.replace(/\.{2,}/g,"."); //只保留第一个. 清除多余的.
	   	obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");	   
	}
	
	$(function(){
			$.ajax({
			url: APP.api_url + 'agent/get_u_agent',
			data: {
				token: get_token(),
				uid: getUid()
			},
			success: function(data) {
					var json = data.agent;
					$("#yongj").text(json.commission);
			}
		})
			
			
		$("#quren").click(function(){
			if($('#money').val()<1){
				layer.msg('不能少于1元');
				return false;
			}
			
			$('#quren').attr('disabled',true);
			
			
			
			$.ajax({
				url: APP.api_url + 'agent/yonghj_to_money',
				data: {
						token	: get_token(),
						uid		: getUid(),
						money	: $("#money").val()
				},
				success: function(data) {
					if(data.code == 200) {
						layer.msg('转入余额成功！', {
						  time: 2000 
						}, function(){
							location.href="yue_record.html";
						});

					} else {
						layer.msg(data.msg);
						console.log(data.msg);
					}
				}
			})
		})
			
			
			
	});
</script>